/**
 *                            License
 * THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS  
 * CREATIVE COMMONS PUBLIC LICENSE ("CCPL" OR "LICENSE"). 
 * THE WORK IS PROTECTED BY COPYRIGHT AND/OR OTHER APPLICABLE LAW.  
 * ANY USE OF THE WORK OTHER THAN AS AUTHORIZED UNDER THIS LICENSE OR  
 * COPYRIGHT LAW IS PROHIBITED.
 * 
 * BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HERE, YOU ACCEPT AND  
 * AGREE TO BE BOUND BY THE TERMS OF THIS LICENSE. TO THE EXTENT THIS LICENSE  
 * MAY BE CONSIDERED TO BE A CONTRACT,
 * THE LICENSOR GRANTS YOU THE RIGHTS CONTAINED 
 * HERE IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS AND CONDITIONS.
 * 
 */
package lineage.packet.server;

import java.io.IOException;

import lineage.core.Opcodes;
import lineage.packet.L1AbstractPacketServer;

/**
 * 魔法效果：麻痹(无法移动).
 * 
 * @version 2014年4月7日下午3:28:48
 * @author jrwz
 */
public final class S_Paralysis extends L1AbstractPacketServer {
    private byte[] _byte = null;
    /** 你的身体完全麻痹了. */
    public static final int TYPE_PARALYSIS = 1;
    /** 你的身体完全麻痹了. */
    public static final int TYPE_PARALYSIS2 = 2;
    /** 睡眠状态. */
    public static final int TYPE_SLEEP = 3;
    /** 冻结状态. */
    public static final int TYPE_FREEZE = 4;
    /** 冲击之晕. */
    public static final int TYPE_STUN = 5;
    /** 双脚被困. */
    public static final int TYPE_BIND = 6;
    /** 解除传送锁定. */
    public static final int TYPE_TELEPORT_UNLOCK = 7;

    /**
     * 魔法效果：麻痹(无法移动).
     * 
     * @param type
     *            - 类型
     * @param flag
     *            - 判断
     */
    public S_Paralysis(final int type, final boolean flag) {
        writeC(Opcodes.S_OPCODE_PARALYSIS);
        switch (type) {
        case TYPE_PARALYSIS: // 你的身体完全麻痹了
            if (flag) {
                writeC(2);
            } else {
                writeC(3);
            }
            break;
        case TYPE_PARALYSIS2: // 你的身体完全麻痹了
            if (flag) {
                writeC(4);
            } else {
                writeC(5);
            }
            break;
        case TYPE_TELEPORT_UNLOCK: // 解除传送锁定
            if (flag) {
                writeC(6);
            } else {
                writeC(7);
            }
            break;
        case TYPE_SLEEP: // 睡眠状态
            if (flag) {
                writeC(10);
            } else {
                writeC(11);
            }
            break;
        case TYPE_FREEZE: // 冻结状态
            if (flag) {
                writeC(12);
            } else {
                writeC(13);
            }
            break;
        case TYPE_STUN: // 冲击之晕
            if (flag) {
                writeC(22);
            } else {
                writeC(23);
            }
            break;
        case TYPE_BIND: // 双脚被困
            if (flag) {
                writeC(24);
            } else {
                writeC(25);
            }
            break;
        default:
            break;
        }
    }

    @Override
    public byte[] getContent() throws IOException {
        if (this._byte == null) {
            this._byte = this.getBytes();
        }
        return this._byte;
    }
}
